<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateRegulationsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('regulations', function (Blueprint $table) {
            $table->increments('id');
			$table->unsignedInteger('company_id')->index()->comment('公司ID');
			$table->unsignedInteger('pattern_id')->index()->comment('薪资方案ID');
			$table->unsignedInteger('field_id')->index()->default(0)->comment('薪资字段ID');
			$table->unsignedInteger('reference_id')->index()->default(0)->comment('参考字段ID');
			$table->unsignedInteger('template_id')->index()->default(0)->comment('条件模板ID');
            $table->string('type')->comment('公式类型');
            $table->integer('value')->nullable()->comment('值');
            $table->string('expression')->nullable()->comment('表达式');
			$table->json('literals')->nullable()->comment('字面量');
			$table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('regulations');
    }
}
